/**
 * Created by baidm in 2022/6/4 on 8:23
 */
class MaptalksUtil {
    constructor(map) {
        this.map = map
    }

    /**
     * 设置地图视野
     * @param pointList:[[long,lat],{x,y}...]
     */
    setView(pointList) {
        let xList = [], yList = [], xmin = 0, ymin = 0, xmax = 0, ymax = 0;
        pointList.forEach(point => {
            if (point instanceof Array) {
                xList.push(point[0]);
                yList.push(point[1]);
            } else {
                xList.push(point.x);
                yList.push(point.y);
            }

        });
        xmin = Math.min(...xList);
        ymin = Math.min(...yList);
        xmax = Math.max(...xList);
        ymax = Math.max(...yList);
        this.map.fitExtent(new maptalks.Extent({xmin, ymin, xmax, ymax}), 0);
    }
}

export default MaptalksUtil
